package Day08_19;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList;

public class Test_Serialize01 {
    public static void main(String[] args) {
        Student s1 = new Student("李明",19);
        ArrayList<Student> arrayList = new ArrayList<>();
        arrayList.add(s1);
        arrayList.add(new Student("阿拉伯",20));
        arrayList.add(new Student("熊某",20));
        try {
            ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("myFile"));
            oos.writeObject(arrayList);

            oos.flush();
            oos.close();

        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}
